package main

import (
	"fmt"
	"sync"
)

// Singleton 单例结构体
type Singleton struct {
	value string
}

var (
	instance *Singleton
	once     sync.Once
)

// GetInstance 获取单例实例
func GetInstance() *Singleton {
	once.Do(func() {
		instance = &Singleton{}
	})
	return instance
}

func main() {
	s1 := GetInstance()
	s1.value = "Hello, Singleton!"

	s2 := GetInstance()
	fmt.Println(s2.value) // 输出：Hello, Singleton!
}
